import { createRouter, createWebHistory } from 'vue-router'

import Home from '../components/Home.vue'
import Trend from '../components/Trend.vue'
import Keyword from '../components/Keyword.vue'
import UserInfo from '../components/UserInfo.vue'

// 第二步：创建路由器
const router = createRouter({
  history:createWebHistory(), //路由器的工作模式（稍后讲解）
  routes:[ //一个一个的路由规则
    {
      path:'/',
      component:Home
    },
    {
      path:'/trend',
      component:Trend
    },
    {
      path:'/keyword',
      name: 'Keyword',
      component:Keyword,
      props: route => ({ query: route.query.q })  // 接收 URL 参数 q
    },
    {
      path:'/userinfo',
      component:UserInfo
    }
  ]
})
// 暴露出去router
export default router
